#ifndef I2C_H
#define I2C_H

#ifdef __cplusplus
extern "C" {
#endif

typedef struct _i2c_client {
    struct _i2c_client *next;
    void (*setup)(void);
    void (*loop)(void);
} i2c_client;

#define I2C_CLIENT_DEFINE(setup, loop) \
    static void __attribute__((constructor)) _i2c_add_client_ ## setup ## _ ## loop(void) { \
        static i2c_client _client;  \
        i2c_add(&_client, setup, loop); \
    }

void i2c_pause(void);
void i2c_resume(void);
void i2c_add(i2c_client *client, void (*setup)(void), void (*loop)(void));
void i2c_write_reg(uint8_t addr, uint8_t reg, uint8_t val);
uint8_t i2c_read_reg(uint8_t addr, uint8_t reg);

#ifdef __cplusplus
}
#endif

#endif
